package com.lww.feature.test.io.pipe.closeinput;

import java.io.IOException;
import java.io.PipedInputStream;

/**
 * @author yi an
 * @date 2017/3/23
 */
public class Consumer extends Thread {


    private PipedInputStream pis;

    public Consumer(PipedInputStream pis) {
        this.pis = pis;
    }

    public void run() {
        try {
            while(true)
            {

                this.sleep(1000);
                pis.close();
                System.out.println("consumer:"+pis.read());
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
